package me.buick.util.jmeter.snmpvisualizers;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;

import org.apache.jmeter.samplers.Clearable;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.MonitorListener;
import org.apache.jmeter.visualizers.MonitorModel;

public class SNMPMonitorNIOPanel extends JPanel implements MonitorListener, Clearable {
	private JPanel GRAPHPANEL;

	private SNMPNIOOverviewPanel memPanel;

	private SNMPMonitorSNMPAccumModel MODEL;

	private SampleResult ROOTSAMPLE;

	public static final String PERF_TITLE = JMeterUtils.getResString("monitor_performance_title"); //$NON-NLS-1$

	public static final String SERVER_TITLE = JMeterUtils.getResString("monitor_performance_servers"); //$NON-NLS-1$

	protected Font plaintext = new Font("plain", Font.TRUETYPE_FONT, 10); //$NON-NLS-1$


	/**
	 * 
	 */
	public SNMPMonitorNIOPanel(SNMPMonitorSNMPAccumModel model) {
		super();
		this.MODEL = model;
		this.MODEL.addListener(this);
		init();
	}

	/**
	 * init() will create all the necessary swing panels, labels and icons for
	 * the performance panel.
	 */
	private void init() {// called from ctor, so must not be overridable
		this.setLayout(new BorderLayout());
		JLabel title = new JLabel(" " + PERF_TITLE);
		title.setPreferredSize(new Dimension(200, 40));
		memPanel = new SNMPNIOOverviewPanel();
		this.add(memPanel, BorderLayout.CENTER);
	}

	

	
	public synchronized void addSample(MonitorModel model) {
		memPanel.updateNetworkIOInfo(model);
	}

	/**
	 * clear will remove all child nodes from the ROOTNODE, clear the HashMap,
	 * update the graph and jpanel for the server tree.
	 */
	public void clearData() {
		memPanel.clearData();
	}
}
